package by.demchenko.sample.webapp.page.home.share;

import by.demchenko.sample.datamodel.Course;
import by.demchenko.sample.datamodel.Section;
import by.demchenko.sample.services.CourseService;
import by.demchenko.sample.services.SectionService;
import by.demchenko.sample.webapp.page.home.BaseLayout;
import by.demchenko.sample.webapp.page.home.panel.AdvertPanel;
import by.demchenko.sample.webapp.page.home.panel.CoursePanel;
import by.demchenko.sample.webapp.page.home.panel.SectionPanel;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.request.mapper.parameter.PageParameters;

import javax.inject.Inject;
import java.util.List;

public class HomePage extends BaseLayout {

    @Inject
    private SectionService sectionService;

    @Inject
    private CourseService courseService;

    private Section section;

    @Override
    protected void onInitialize() {
        super.onInitialize();


        final List<Section> allSections = sectionService.getAll();
        add(new ListView<Section>("sectionsList", allSections) {

            @Override
            protected void populateItem(ListItem<Section> item) {
                Section section = item.getModelObject();
                item.add((new SectionPanel("section", section)));
            }
        });

    }

    public HomePage(final PageParameters parameters) {

    }

    public HomePage(final PageParameters parameters, Section section) {
        this.section = section;
    }
}